﻿using System.Diagnostics;

// 静态数组  int[],float[],double[],string[],char[]
// 数组一旦创建，容量的大小是不能变化的 
// 动态数组 list<>,arrayList<>
// 根据元素的多少动态调整数组容量的大小

using array_demo.Model;
using array_demo.Model.Queue;

static long GetXnTime(IStack<int> stack, int N)
{
    Stopwatch stopwatch = new Stopwatch();
    stopwatch.Start();
    for (int i = 0; i < N; i++)
        stack.Push(i);
    for (int i = 0; i < N; i++)
        stack.Pop();
    stopwatch.Stop();
    return stopwatch.ElapsedMilliseconds;
}



Console.WriteLine("开始");

Array1<int> array1 = new Array1<int>(20);
for (int i = 1; i < 8; i++)
{
    array1.AddLast(i);
}
Console.WriteLine(array1.ToString());

LinkedList1<int> linkedList1 = new LinkedList1<int>();
int value1 = 0;
for (int i = 3; i < 10; i++)
{
    linkedList1.AddNode(value1, i);
    value1++;
}

Console.WriteLine(linkedList1.ToString());
linkedList1.Remove(5);
Console.WriteLine(linkedList1.ToString());

ArrayQueue<int> arrayQueue = new ArrayQueue<int>();
for (int i = 1; i < 5; i++)
{
    arrayQueue.Enqueue(i);
    Console.WriteLine(arrayQueue.ToString());
}
arrayQueue.Dequeue();
Console.WriteLine(arrayQueue.ToString());

ArrayStack1<int> arrayStack1 = new ArrayStack1<int>();
for (int i = 1; i < 5; i++)
{
    arrayStack1.Push(i);
    Console.WriteLine(arrayStack1.ToString());
}
arrayStack1.Pop();
Console.WriteLine(arrayStack1.ToString());

LinkedStack1<int> linkedStack1 = new LinkedStack1<int>();
// for (int i = 1; i < 5; i++)
// {
//     linkedStack1.Push(i);
//     Console.WriteLine(linkedStack1.ToString());
// }
// linkedStack1.Pop();
// Console.WriteLine(linkedStack1.ToString());

long linkedTime = GetXnTime(linkedStack1, 9000000);
Console.WriteLine("linkedTime:  " + linkedTime + "ms");
long arrayTime = GetXnTime(arrayStack1, 9000000);
Console.WriteLine("arrayTime:  " + arrayTime + "ms");




Bst1<int> bst1 = new Bst1<int>();
int[] arrays = { 50, 17, 10, 34, 63, 54 };


foreach (int item in arrays)
{
    bst1.AddV1(item);
}
bst1.PreOrd();

bst1.MidOrd();

bst1.PostOrd();

bst1.LeverOrd();

Console.WriteLine();

bst1.DelMax();
bst1.LeverOrd();

Console.WriteLine();

bst1.DelMin();
bst1.LeverOrd();

int height= bst1.MaxHeight();
Console.WriteLine("高度" + height);
Console.ReadKey();

